//
//  SpecialDetailTableViewCell.m
//  味·道
//
//  Created by lizi on 15/7/1.
//  Copyright (c) 2015年 WMR. All rights reserved.
//

#import "SpecialDetailTableViewCell.h"
#import <UIImageView+WebCache.h>
#import "MaocHeader.h"

@implementation SpecialDetailTableViewCell
- (void)dealloc
{
    [_picView release];
    [_titleLabel release];
    [_titleLabel2 release];
    [_jianjieLabel1 release];
    [_jianjieLabel2 release];
    [_bcgView release];
    [super dealloc];
}
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self p_setupSubviews];
    }
    return self;
}
- (void)p_setupSubviews{
    _picView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 80)];
    [self.contentView addSubview:_bcgView];
    _bcgView = [[UIView alloc] initWithFrame:CGRectMake(0, 80, SCREEN_WIDTH, 40)];
    [self.contentView addSubview:_bcgView];
    _titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 95, SCREEN_WIDTH, 30)];
    _titleLabel.textColor = [UIColor whiteColor];
    [self.bcgView addSubview:_titleLabel];
    [_picView release];
    _jianjieLabel1 = [[UILabel alloc] initWithFrame:CGRectMake(10, 130, SCREEN_WIDTH-20, 90)];
    _jianjieLabel1.numberOfLines = 0;
    _jianjieLabel1.textColor = [UIColor grayColor];
    _jianjieLabel1.font = [UIFont systemFontOfSize:15];
    [self.contentView addSubview:_jianjieLabel1];
    [_jianjieLabel1 release];
//    _titleLabel2 = [[UILabel alloc] initWithFrame:CGRectMake(10, 220, 200, 30)];
//    _titleLabel2.textColor = [UIColor greenColor];
//    [self.contentView addSubview:_titleLabel2];
//    [_titleLabel2 release];
//    _jianjieLabel2 = [[UILabel alloc] initWithFrame:CGRectMake(10, 260, SCREEN_WIDTH-20, 100)];
//    [self.contentView addSubview:_jianjieLabel2];
//    [_jianjieLabel2 release];
}
-(void)setModel:(SpecialModel *)Model{
    if (_Model != Model) {
        [_Model release];
        _Model = [Model retain];
    }
    _titleLabel.text = Model.title;
    _jianjieLabel1.text = Model.jianjie;
    _jianjieLabel1.frame = CGRectMake(10, 130, SCREEN_WIDTH-20, [SpecialDetailTableViewCell heightForStr:Model.jianjie]);
//    [_picView sd_setImageWithURL:[NSURL URLWithString:Model.thumb] ];
}
+ (CGFloat)heightForStr:(NSString *)str{
    NSDictionary *dic = [NSDictionary dictionaryWithObject:[UIFont systemFontOfSize:15] forKey:NSFontAttributeName];
    CGRect bounds = [str boundingRectWithSize:CGSizeMake(SCREEN_WIDTH-20, 0) options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil];
    return bounds.size.height;
}
+ (CGFloat)heightForSpecial:(SpecialModel *)model{
    CGFloat height = 150+[self heightForStr:model.jianjie];
    return height;
}
- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
